package com.chuantou.yuba.api.to;

import android.os.Parcel;

import com.chuantou.yuba.util.Constants;
import com.google.gson.annotations.SerializedName;

public class NewsDataTO extends BaseTO {
	@SerializedName("data")
	private NewsListTO news;

	public NewsDataTO() {
		super();
	}

	public NewsDataTO(Parcel source) {
		super(source);
		this.news = source.readParcelable(NewsListTO.class.getClassLoader());
	}

	public void writeToParcel(Parcel dest, int flags) {
		super.writeToParcel(dest, flags);
		dest.writeParcelable(news, flags);
	}

	public static final Creator<NewsDataTO> CREATOR = new Creator<NewsDataTO>() {

		@Override
		public NewsDataTO[] newArray(int size) {
			return new NewsDataTO[size];
		}

		@Override
		public NewsDataTO createFromParcel(Parcel source) {
			return new NewsDataTO(source);
		}
	};

	public NewsListTO getNews() {
		return news;
	}

	public void setNews(NewsListTO news) {
		this.news = news;
	}

	@Override
	public int getCurrentPage() {
		if (news != null) {
			return news.getCurrentPage();
		}
		return 1;
	}

	@Override
	public boolean hasNextPage() {
		return news != null && news.getNewsList() != null && news.getNewsList().size() >= Constants.DEFAULT_PAGE_SIZE;
	}
}
